package com.leyou.item.controller;

import com.leyou.item.dto.CategoryDTO;
import com.leyou.item.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/category")
//@CrossOrigin("http://manage.leyou.com")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    /**
     * feign在调用处理器接口的时候，如果参数为简单类型，必须有@RequestParam来规范名称
     * @param pid
     * @return
     */
    @GetMapping("/of/parent")
    public ResponseEntity<List<CategoryDTO>> findCategoryByPid(@RequestParam("pid") Long pid){
        List<CategoryDTO> list = categoryService.findCategoryByPid(pid);
        return ResponseEntity.ok(list);
    }


    @GetMapping("/list")
    public ResponseEntity<List<CategoryDTO>> findCategorysByCids(@RequestParam("ids") List<Long> ids){
        List<CategoryDTO> list = categoryService.findCategorysByCids(ids);
        return ResponseEntity.ok(list);
    }





}
